#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int a[300] = { 0 };
	string s;
	int max = 0;
	for (int i = 0; i < 4; i++)
	{
		getline(cin, s);
		for (int j = 0; j < s.length(); j++)
		{
			a[s[j]]++;
		}
	}for (int i = 'A'; i <= 'Z'; i++)
	{
		if (a[i] > max)
			max = a[i];
	}
	for (int i = max; i > 0; i--)
	{
		for (int j = 'A'; j < 'Z'; j++)
		{
			if (a[j] >= i)
			{
				cout << "* ";
			}
			else
				cout << "  ";
		}
		if (a['Z'] >= i)
			cout << "*";
		else cout << " ";
		cout << endl;
	}
	for (char i = 'A'; i < 'Z'; i++)
	{
		cout << i << " ";
	}
	cout << 'Z';
	return 0;
}